//导入路由表
import routes from "./config";
import React from "react";
//导入路由组件
import { BrowserRouter, Navigate, Route, Routes } from "react-router-dom";
//404页面
import NotFound from "../views/Error/NotFound";
//创建路由组件
const Router = () => {
    return (
        <BrowserRouter>
            <Routes>
                {
                    routes.map(item => {
                        return <Route key={item.path} path={item.path} element={item.element ? <item.element /> : item.redirect ? <Navigate to={item.redirect}></Navigate>
                            : <Navigate to="/404"></Navigate>
                        }>
                        </Route>
                    })
                }
                <Route path="*" element={<NotFound></NotFound>}></Route>
            </Routes>
        </BrowserRouter>
    )
}
export default Router